package com.mijie.homi.admin.web.user;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mijie.core.Paging;
import com.mijie.homi.admin.service.user.IntegrationService;
import com.mijie.homi.common.domain.Integration;

@Controller
@RequestMapping("/integration")
public class IntegrationController {

	@Autowired
	private IntegrationService integrationService;
	
	@RequestMapping("/list")
	public String list(Paging<Integration> paging,Model model,HttpServletRequest request){
		integrationService.listIntegration(paging);
		return "integration/list";
	}
	
	@RequestMapping("/create")
	public String create(Model model){
		return "integration/create";
	}
	
	@RequestMapping("/save")
	public String save(Integration integral,HttpServletRequest request){
		integrationService.addIntegration(integral);
		return "redirect:/integration/list.shtml";
	}
	
	@RequestMapping("/edit")
	public String edit(Model model,int id){
		Integration integral = integrationService.getIntegrationById(id);
		model.addAttribute("integral",integral);
		return "integration/edit";
	}
	
	@RequestMapping("/update")
	public String update(Integration integral,HttpServletRequest request){
		integrationService.updateIntegration(integral);
		return "redirect:/integration/list.shtml";
	}
}
